package site.comic8;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import org.apache.commons.logging.*;

/**
 * 動漫無限漫畫下載器
 * @author shen
 * @version 1.0
 */
public class Comic8Downloader {
	
	private static Log log = LogFactory.getLog(Comic8Downloader.class);
	
	private final static String SAVE_FOLDER = "C:/tmp/comics";	// 存檔路徑
	private final static String SAVE_TYPE = "jpg";				// 存檔型態
	
	private static String comicName;		// 漫畫名
	private static String comicId;			// 漫畫編號
	private static String volumnNum;		// 話
	
	private static HttpClient client = new DefaultHttpClient();
	
	// OnePiece CodeDb
//	private static final String codeDb =
//		"1 8 2 103 8a7tgkhpavvwcpv86tq726ka9drqh8yjfdqtaq8b|2 8 2 99 frrraev4c3dkbn6fagcjkmsdbp2g3nub6tqgeua8|3 8 2 99 52eqqq72vn9n7ghwsgxgqv8j9wxddn5qmeyr35mp|4 8 2 94 52eqqq72vn9n7ghwsgxgqv8j9wxddn5qmeyr35mp|5 8 2 94 y8g7t3794ucsjjkqju2953fy4yd5ekqsfpfqwr73|6 8 2 94 gqk5xpc3vj367sqwhedpttw6t7pasj2x3tkfa2cr|7 8 2 95 ddufgpe85bq5ptkk73j76rt5abew47eqw6j6yujw|8 8 2 95 tfx6he34cx74byce2esrqhgxvyrdfhrhk8b7nr2a|9 8 2 103 5wpy9vxf53xn673askmhqkdk5w4pkrymfyy2r4rw|10 8 2 95 w62n67dks79ua7mguh53j63nmuvp9ykjag9bfh8j|11 8 2 95 sjhuwa55mqajky5v6tjvjtkw4gsyd35hbugyvrs4|12 8 2 95 pgddajyyjrbveyx7h99npd54df9e8gyrushjuxv6|13 8 2 93 2jmshhxn7d2am53s3mmrt6qswwem2g7p3y6hcvbv|14 8 2 95 37kshh62jn5deb6797putbtpxrybmcwya7594um9|15 8 2 107 b32sw2nk59x6djshux6hxdte9y9v557yqumjp6p5|16 8 2 95 e9usshmk9gvfy885v5umvuwm9h3c5gfgtywy43rh|17 8 2 103 8scn9s6ryustym4xgcxy5eccryb88axnwhstd45f|18 8 2 111 eadeychaet749d74dr2pcej87bj9qq37rt4um2cb|19 8 2 103 6at7efc8xxn2xh6cxhbjcu5jqxv2u4mgdpa4dyh8|20 8 2 102 59pa6aa5mm43kbbuvry4nragnsjwsx3qr93p6nj6|21 8 2 96 8scn9s6ryustym4xgcxy5eccryb88axnwhstd45f|22 8 2 106 cdgtej9rsdg89nuqyr7jffcdrvj9e33nuf5e45tt|23 8 2 116 yqtfccfjwkxp7rndmv5rvct6d4cdxbch3bfsvwyy|24 8 2 107 sx27ygtk8dnxyhe4m3at2sm8ttt9hcdq9dhpbxgk|25 8 2 106 fmvegu5g4xq66g9ahh3quh56p8tm2nwuvdjqy2hy|26 8 2 93 je4ggwvhu7n9e599wa6qxgchmt9gk79eq5br7enx|27 8 2 90 jh8tr4b5purbgbnt64xt2uxjujfcnm3qwh56n7s7|28 8 2 89 qbhvw5eun4aj5af7tc3bt3aupkcbfkndbmgeukty|29 8 2 112 3rrqkbhqeug9v4e8ctpf27whuaqx7pab4u3dbkbw|30 8 2 103 kgwd9hbmmxrkvbmdh72xac9s3rkmmwycfkwgdu9x|31 8 2 102 tmxdk6vsxdeguc44u6e45r28knaejp9rg3pccyrj|32 8 2 105 ffrq382j9ykrv6qab89yh53ym434tvjverpyqp57|33 8 2 112 c9s7qg5p6assmf9srj3xx3edg87hfd4wgdq8ks3y|34 8 2 114 76dssmrw964mbxke8qtdagegtheqcanax4qf8m42|35 8 2 92 3rrqkbhqeug9v4e8ctpf27whuaqx7pab4u3dbkbw|36 8 2 103 qbhvw5eun4aj5af7tc3bt3aupkcbfkndbmgeukty|37 8 2 114 9a9ehm3kd4xkqfujadhuxw4hypnj7bc6rxxksywu|38 8 2 105 sykt7bpbdqyk9qd35nfvgc9trka65mxe88njvw4d|39 8 2 107 8wpv8c2d459tqadk8vttkqumfw2f3v5ma297dvh2|40 8 2 115 au8wtbq35hmf7x8nnhpshtk85rxdxy4uf5xn6wpp|41 8 2 113 x7depnt9pw7kwvpduf9enss25eu732sm38q8gej2|42 8 2 105 k9yjy6rmjvrkvjcve6ede48qmpc9nr78aeejx8gp|43 8 2 110 vappt82rc4umjm95w6fy5rge67ckjj7pbxerfkau|44 8 2 117 vm9yfbks9k9tk6vnusv4majsurgupjnj8p326b4f|45 8 2 106 rcn7y9n6dbks8n39ed9djpfjnm2f8qmdr78vncsa|46 8 2 101 m8qmastsje8rrkkqss77bm6gr5wsud7ey6sq7v23|47 8 2 105 n9tvfvrfa6h8xcndtgq2t69ppe9a2yydw3puckg9|48 8 2 112 9tcw7ycqgrpqdd2njmyfmtjmgywuade38nyw2bjc|49 8 2 113 hdqxv8ysaqf7jaba4faxb892mdarta25s95psb5d|50 8 2 102 wskuwv5my2c9dg9wvwu9kxqxg9y9ng2334mpeudd|51 8 2 112 aft7q7y4pcbw76dyrwvbw6x443v47cs9a25b5cdd|52 8 2 107 ehxkw7bc7htusgw36tb527hfprffk9heutby7pxy|53 8 2 107 7m6hbkbkhx8ehsxvy3cb6b7rkkp4de2v6929xhq4|54 8 2 195 nqwerh6hdtpv5ha92tft57rynq7fshvpspmvmbku|55 8 2 184 76bg5j4sumfg3urj9xjvn52xug2k2572472tu88h|56 8 2 107 e8e3h6bsxurcdg25w9ett8k5tfw8hfmgrvbmb932|57 9 1 158 2gvex28n8ggf8cc44suyw4dpt35h8dfbjc5as6we|58 9 1 106 q5hrr24ftf8qrta7hkj7dvye99mfxfks3ahcx5ng|59 9 1 105 ckjnkgrf9vwd8tmmekmpxmfr44mw6mvjnsxbukub|60 9 1 213 ve7j4gg7u9xh933wvg5c5hadjbckfmhq3ku78nvm|61 9 1 101 h7wyw9yg76m446a8wd4qs2tdb7ded3w9qjrcjm2n|62 9 1 213 4pbderm5n8f28nvx4y7fkyhfbct8rxt8aa8mn4vw|471 8 2 18 rwqkututcfpbfhdnvvhmrn3nbkrtgjhwfhnn4xbu|472 8 2 17 bkgv7rna874rdyw96f5nkj6dnn76xextwgcf2t7v|473 8 2 18 apxkg7t7hxgrtn288k5wy27jq35wvnyhusacmq82|474 8 2 18 kc8qf8w22mqp5mgc8jyex4sst5j927xxapafexn7|475 8 2 18 usew2uwnmd7mnm79g5n5hj3s59dnj6mc7msfycsy|476 8 2 17 u88spx892vgdj9rgs7peeetde9492r9nuj7ksrc2|477 8 2 17 7y358caudfepx7hsukpq2dny5x6xvwcs3w3jwcbu|478 8 2 15 fpnr8gdsk7cy2hbj4ckt66yq7qdv3rh9rvumcfws|479 8 2 15 vgerttnrtvj5uxmadyydxg9a9g56uaxerxv9f58s|480 8 2 17 6vqwf4h8phgy893vn989x9fx35t8n29bqgbjx3dj|481 8 2 17 rdp7ehd848xx9jucxte653y9thapk9qcrgkdhbkv|482 8 2 16 539y2gakyjnspeysr6x33ky332efpu8xqdknykev|483 8 2 18 jkmuqyjkhv7vgxepe2u6agn9kkg5qxjnqcu49ssj|484 8 2 18 wkkfww9j2fegnase63m43c7we3m3kq6xrh8rfab9|485 8 2 19 2puutterfrx47grkudaskvgs79grteufu2dkre88|486 8 2 19 txtvnyperx2dwckxp2epq6n56qf4th4bmt75j5xr|487 8 2 19 de6wxcruyvb23ebhwfxmrsyev2dksdr6uqnrugjf|488 8 2 18 63u5523kg65feaph7ejbsh5cy8ykpnuhqcrhvxcx|489 8 2 16 y3qgg8r4tcm9kg5jkbv3ejxaqfdwu9jqgn6ckbvq|490 8 2 18 wkyxkwc7p6j7nempqy54g4b62da76kkubnugjssa|491 8 2 19 ktapsxnnjadvxkt4sqt243jxq5b44tjj5aw72tu9|492 8 2 22 yupudwdd7ft7kkdftyeha8hvg5mpxfaf6emuwcf8|493 8 2 19 rqkp5wm2au5m6r5hwqtk7a3h5evukqa2m52b67v4|494 8 2 18 pb3726qkuaj4337fcwvxdtfvrp2vcga4etcbaej9|495 8 2 19 w7hqvetyvqyvgqpu9beefqed6fbuh4p5sxgcfhxv|496 8 2 19 8bgbbnd5w96xbtktu6ms5wdah2pmhq6paydypx5d|497 8 2 19 s4ghp363d9jq3bh7yyaye53683erh9cwysxd6r2u|498 8 2 19 74g2n4h54u4u279ktaxstte795p2dggprs9gfxa2|499 8 2 18 g69ebydebeunsrsdq5f7hj2vu38jtftbq5t4j2at|500 8 2 19 sa9mvfquu2gnfae8dw5ukbmejnxn5bbne9mqf4hx|501 8 2 18 s9fc2wc5tmvx6jkm7fw6vfbcakfgs3xgw54dkqyq|502 8 2 19 69mhngp5etc4maqywwq56nkd8ger9qwn83v4eake|503 8 2 18 rpqu4h6ns59y3ce9q9qq794ah5cua5tm2uygfqxs|504 8 2 19 a2x6423ud8mdqdkv7duem4xvakmd9s43cwtfcjuq|505 8 2 18 pu9p9w9g56agqh8wkaepu6vdexgdhhps8pt5t6y7|506 8 2 19 m7daq6tet4j22fvxxpfqqehmvw2ggxwkjkkfvctn|507 8 2 17 m8d2jj9n7mb66ffwr6qdxm5vwakdhtpbpqdvwsmh|508 8 2 19 psv97myrcwbr93yjgjbh3xd8gesedya4gehbr54f|509 8 2 19 k5fenuhs7x9p5ghgvddgv729wyxvdwgpga9qkrbe|510 8 2 18 n25cyc9j5a536xxkqrts2rg5q2uct8c2u9bck3se|511 8 2 17 x3wmtscpfpcxxrkwc5gnqnp28undxu47v3dajux2|512 8 2 18 j4bg4tenywcf3suxswyg42f38b7wc3pw9fnnx9ps|513 8 2 18 ekj52gh5665xjaug28n6t5q9wj8e2sdgrwj39esa|514 8 2 18 7yra3dgyjk6wetv822v654w72aer88a3pfpffgnb|515 8 2 18 h9gxgvm5mdfk33nv43q4tuhncjr6fbcf3xsc3xu5|516 8 2 17 uyxd5hg7kxp9qskrb644kkkxdeqcs7jghhnty6am|517 8 2 19 mrwpuq7kr89teaq8brmgv2h2u95acep5sggsdnww|518 8 2 19 5stbb9t9ukcbmmk36sbg8a3fhpd243xkcnb5r6qu|519 8 2 19 eeurpgnjvjwc4y9mxmngfgjc2xxqmtdtva6fuj2v|520 8 2 20 fxhb7h7mk5w4qr4qexh9bbjrqxxhh9582af86sxn|521 8 2 19 nudmswmwq6vxsapu5uk7c767wegqx26224jf456t|522 8 2 19 uynq8ubuavjhyv7cmd3pv4fk6wkn3uudvvdh648p|523 8 2 19 grfme86hq2h87rq25ft4vdfu9gvma2jhbdmquefm|524 8 2 18 a84tb7fme9jshjtxmf5e5nk9ub82cd97uxc6mr9c|525 8 2 14 5cj42yjjyw53b7w5bt89c53h7cgt4grqpgy5yjjt|526 8 2 20 pdsgpbbq2gjtjyt4rcbueuxgxhvb97px5kdq7nj3|527 8 2 19 2et8rjh9ky29vp9m6cxvuxwqkans9sk6k6cq9d44|528 8 2 18 94555hwcs6er8n8yjdkc6xc876p3q4wty78duat2|529 8 2 16 8hnvt7q39axpb32tr4fjgrfsssrckx36kcatmsew|530 8 2 19 uxrt9je96r8htd72ar7st282pqab6tt63uy3nug6|531 8 2 17 9c8apw75urn9eekkeshkxjyk6mffjeaqw759msbg|532 8 2 18 92urt88gwvt4bkdk4hxntk5f6kggu2wmy8wm643p|533 8 2 16 juhcxvmey69t2puns4anjsrjvhv9xdjxcruuntpj|534 8 2 17 fvedgw2nrax23q2w6fcswf3qgrhw6qvja9xjda6x|535 8 2 19 8y9aap6vngbx5k558295s6tys2rs6h6uwbaxakbq|536 8 2 19 ur8wer2g4u446egshdebdndj6557hxh8q2u7fe4f|537 8 2 17 p65he5xrf9sbj3nvumywv6a6psfm459ttbce47y4|538 8 2 19 9w8ae65q974ywggkra9a5uu9radanydh5sysnkst|539 8 2 19 47smq64898hp2esnqx7wc9xd2t63syq9k653bxpu|540 8 2 19 tapj7ge7g5t45bunu9dprsr2menbks6xkp6cbh7r|541 8 2 17 pttjkc7xtwfn2epqheq4teeqn69hdcy9qbfngfwg|542 8 2 16 ah4gg9ksvyetf8863mps926avu664rshg3qyeue5|543 8 2 14 kxbkxdu475n32jwuqnra23j3hs3cexmcrsdspymk|544 8 2 19 abmvxqwk7rs5ed4bsdgwa64qc63dgr7h346vxrmn|545 8 2 17 j4mtcmbsby4dhdku7hb5ae3568w2kdww46td5b6t|546 8 2 16 w4wgkjeab7s4x7474pfspxj3a3tpaqbjgss9sa35|547 8 2 15 ujr66bajrs5sn6dkvy4npsbxckbv7q7kejykrmhv|548 8 2 34 mva73dj77jf2qkyf9majg5fcwtsa2hqjgbyu5ywa|549 8 2 19 rjnp8mqdxgasm77as2nrjp85w7gcf5um949q39tq|550 8 2 15 q9b7sjds7x8d7ry8678baf43pfxs8dhnh2ury8pa|551 8 2 20 nj4ch9nsp5mcewu5kx3ggg42qeyf6tmc8et9syra|552 8 2 16 g6pspd962hn3kkqq6u5jvrbgv5ttrkqkmdrqn7yp|553 8 2 12 sym9uc27qkerpq336923espp22npgwb5795hx8ks|554 8 2 8 kc6pqwq6e7wyugbm3x9xdqqsnvjm6ftq6veemwsu|555 8 2 11 69pqhm3na5fcqpcrdgjhgqhckdd7meks34h9tnxv|556 8 2 12 ybjwc2ne5v944vjfhxa8ggs3kwpt9dqwqbsjw86y|557 8 2 14 w2c4y4ugqp8g3dqy624khp7ntxbrp3pt6x53ve6y|558 8 2 13 uuh8byagp2w9ny2ab7sm7bbt9hv7ghvybaqsnbtd|559 8 2 15 26mny2rn3h34bkxtsc9a39c6rtd63gfcwt8jm3sq|560 8 2 14 fwgemvvb2t9seu8q5wh5wxwtpp2hk9rvwhg9fg9v|561 8 2 15 knxtgqjqunmdweq5eyrjmeauqk5dcsthnr6h84qy|562 8 2 15 sjwfby3v89qsjcapa5tktwuaj4gmve4c2errm7u6|563 8 2 13 ghw2jpqhv936wtdfv6rnwdabcqucu9pksmkh2q2y|564 8 2 13 snfuym5m8f9qbs2kjt43sgfh78knrrpgvxpsfp43|565 8 2 15 3fr9txhvu6wtkttdg2frtn5v7t5srvvhndmvr34s|566 8 2 13 qqtfxse75mfc5egf3rxdcagfv642hy23hypmqdvw|567 8 2 16 9kkxa4arerunj5gnaarvh6xnpx4px76476k9kd7b|568 8 2 13 d655teepfcquhpgu5j4abejf84a4whq733bqjr5v|569 8 2 10 69tj5uahq72raaufqnr6gheaw587p36pq8g5xpw6|570 8 2 13 vd4qxbg4m8d5uakbmfmkg8mnp8km7duh4tdjvthx|571 8 2 13 47uwrpre5td9k8v2mbqpr5n542k66nxvuhtwe58a|572 8 2 12 s7cy7neny63fdysbbj5umpvs9petbhfe35wx76du|573 8 2 14 f5g63cpw3mcbw7arn5fnjegsyqqx2wf9w7fpa4cf|574 8 2 15 kd6gkqmhdfsdqdp75pu4a37t4ftswta5rfpnjg2x|575 8 2 10 pjk3j28t849xm9c3n4x3yff3b4kyu27qt2nvr9g8|576 8 2 13 e8qa7nradhanrfegcqckhnjymnwwmgacwk5kgvpq|577 8 2 14 sng673wdf4xpsse6ccxgc2r336rdxwg8mn2ujnh3|578 8 2 15 qjcfawb2bksb64x77dnjd6a68ervb5partv83rr8|579 8 2 14 3tg8wgfe5gqebrey9smuwmnxbkg3evu5tkpnq2tx|580 8 2 12 2d4uwxmstmtyrgugsaf3wxhb4qbeha8dwnk98b6d|581 8 2 17 mxqaewyeapdjgvyxms6yg2fg3242agwnswgvksan|582 8 2 18 3k876pyn8utd333x9epmvgcs5873as8h89vkrqdq|583 8 2 16 exy7w73dkt5gg364y5vef4ynwvje3unnun775wpn|584 8 2 17 epgjj66jvymst49btuu383uu9duqv9cp2bsmjgsj|585 8 2 19 a97kg987mekucttj4wxnxu23w9qn7y65phtew89m|586 8 2 19 cbyxp4hcg8p258vx69v9jnp64mcvgvx343jrd3p2|587 8 2 19 yt8a8enx8eh8xmdc5myvr56s85nxq5jncgmy64mn|588 8 2 18 cnwp59w62cyrwa4mqvrvu83nf6s2bvtnh3y43nff|589 8 2 19 w85fsds8yptx94qr5q56kkg9r2dbpng7uqrdda7r|590 8 2 18 a8pmcxw77qdeaqt73yhbcac4wdbwh4enfvxdu9gs|591 8 2 19 7h9h4tv6q7v6y2jg7jpgkdwja6jp2dvp3pcny5d9|592 8 2 18 ypsvkk3nhmxub3tddtfqqreqbq7m7bmgww3dxq7g|593 8 2 19 tqm99caag8rpy9nb8xxjkbd7xgwkt9g47a2ex8yk|594 8 2 18 e5upamnhgh7usrn4p24rbfsvnrejsqy3dt9b4aqt|595 8 2 16 dpfbb4tv7nad7g4k8hwxcsp9ew9ww5dcgv6wkk39|596 8 2 19 aheve2n3j2esh6ucb75nnj27pqxgehy2ya48pv9b|597 8 2 16 vyrqs5s549mgytcemdfqg8h8rkrrgusyqup6x9dg|598 8 2 21 ehut4csgg8cc6399uch6b2qy2gxfqjpepghwubew|599 8 2 17 gq3jk43ush32mm5andr8tbansf7637spuxkwa9ry|600 8 2 18 e4j6b6tj5vvnynmfr8nvwrtf63vhm5yb9umst822|601 8 2 15 swucysttrek4ccavcew7h7fu4vjrfsku5jvrmguk|602 8 2 15 8e2enyv7efwhbr9wbbegy4ajj32777t3mpf3t55f|603 8 2 16 2bwppgrwbfyf2wa57a99eh4h4556faw9u4q3j6m6|604 8 2 16 u9qvceqh7s4m82sk776br7y7y2cc295y253uxsqr|605 8 2 16 dfexc5q6kr9epx3tgxhc53qpqgmujek34kpwtkv2|606 8 2 17 f5w4gn62n4vqks4ax66bwaey6qgs5xuhj3pg6qmm|607 8 2 13 87vra7c2ua2rx6fa42m93tv2erjjm2t3sw2hvtfx|608 8 2 17 28t7qbgbmc7e454568pqtvybfsxvv6yf8x7wkmam|609 8 2 17 rfqe2kcsgqdqatsshkgufh7ef4mtc6v6bp39kqyu|610 8 2 21 m9c3vba4a98g6dkd6tqrptqe52ya5tm8664wq9cd|611 8 2 16 jhxe45hgu5x5tb79fku5fewxwunvutx42bqf23hk|612 8 2 16 4eqaqm25xakxh2maunrtdk667pyhy8u2sm8g2qsj|613 8 2 19 9jvw2652wra869fqbcku644e8vjavjwfnj6bxssg|614 8 2 16 ec2kpb7mmy3f683d6wmtgacmxjtw7q6gqrxdd2hp|615 8 2 17 h5pfec39dtfk5jhvppkx3p368pm5d5fyrreemv5k|616 8 2 22 kw4p9ypxef972auem9rfpspbncv57ahgw9qj2hme|617 8 2 17 jxvkdvw8ureyxskycamcxcp7skkw8ddhpgsfwypd|618 9 1 16 pcxcqy9a84d2w5sfffryq4bm2pkq4um9r7vabmca|619 7 2 15 txafd8d373pbrungfxektjv8mbx4nwpppfu5aem4|620 7 2 17 px2bn2xj5qtuhesufudr3evh8xgv3sq4gkp5ca2c|621 9 1 16 rmgyg8epwayf6neyr8fpv6ayfh6nw98448g967mk|622 9 1 18 3rggdex235xvkewceuq84cj2btce6ygah8jgd43n|623 9 1 19 eypeq644k5ugkptgpu5qy8xhqjtktuwt8rrwjse4|624 9 1 17 sndgtyd7npudwa8wj9mrugrmjwwqt27nk4n59y66|625 9 1 18 sbyec6g5wh8aaqw9mx2vrevw93dpyeskfjdvb9cd|626 9 1 19 r5bnu3rb9yu8dhcb9cbt5rgfcr272cu74jks72j7|627 7 2 22 4dt4qw8fef3s4exgchhu63fcmf3cvwru5p66rnrq|628 9 1 18 p56esh79wwyq8ydxjtxbc2f5cve8wgnh9mq2xjdv|629 10 2 18 enb46sayurds8scu6m7dgu3xhjvck2y3pd8mdftj|630 9 1 18 8pnaa4vx3en87449rd56s9tyj4smrf39sfcqhrmu|631 9 1 16 3855pus3gvrj2vchxe9aajn4vbshpmx42qae6r2p|632 10 2 16 curvjd4da5rgkuj8vwarw8m9fjsfaxmes78gqgmh|633 9 1 16 b4jhaxv2pxhxh86u6mq5t5ryytbk2teqvun3saej|634 3 3 13 c7j8rfwpyp747pbcayvqg93e9ptcdrudwy8wremc|635 11 2 17 jfp8htu7vqakk65h3h8gfsbfkxfjwajyehnyn8ak|636 11 2 22 cgxc4ua7rmbtdh3dx27svkhtyfehqv2tbx9g8uwk|8001 8 2 19 6jf8uxytke64xew4tebhbb33x2emsd2p32jnd3j5|8002 8 2 19 553vue669jamc6bkcw6qbnxeq79yvtdy64f9vcvj|8003 8 2 36 88et8j87nanvjecnksbcftrqmq7sgpay4uaewfsb|8004 8 2 30 e9fft6qajp6n9rychyq6k2dn32fk4nkuubsx8b5v";
	
	// 史上最強弟子
	private static final String codeDb = 
		"1 3 2 97 6tpsgxxmc2rw3tpx8u528ms8sttrjkreef3qgjby|2 3 2 100 5gbr358axqnsyycg5sp57u6wrdd3hdhacfg6458a|3 3 2 98 rfbae3ct4qt5v7jkbptpk8sa2aybchcvk33uf4xh|4 3 2 98 vx58m9k7s24gfj2q3j6efya3cah5ppaw6gv46b9a|5 3 2 96 xf3kw52wafbwh6qny7gx79gebarabt3yag9n2hr8|6 3 2 98 sujsq8qf6ydmtx82agwr7w2ptxnjfwkxbvgbfrbr|7 3 2 99 v83mwwbpbtbv3f4xpqydgg8dweckdckua9952cs6|8 3 2 103 xjywe59dw6pb8b9xcwnppt2538nhvgt33tv76895|9 3 2 100 qcmedcbqnj58rch4duj8fntatwedurtv7u6rkjtt|10 9 1 98 qrqqgcwwbkhkw4u89fgrtfrha9ruf395gfaykyeb|11 3 2 100 qmjtp3277cdmcakby2e8f6rmd38vjf5tbmgrekcp|12 3 2 98 u99k4m2w68dmwgb3x2stasd9brxsbfsg8dw8nkpu|13 3 2 96 pk87bcbm82tnf5fkcfvgjc6cx44keykbsugs8qd9|14 3 2 97 ppqsuqrf2rfb8ateab7nafwgtdu4gjbf9r7u4t9d|15 3 2 104 n4a8se354fbg5ng9x4djukakvv5fgt8hf2pavwuj|16 3 2 100 ery9ubnsmcq7ryw4tqemph8fxhw8phna3nb54cby|17 3 2 100 ht2kts393qjg24see23hxuggf3qr6xytfn6awj8b|18 3 2 99 xf6gk8ntpnbk5y449vj48q9kg9qa68kbbsfdhdvh|19 3 2 97 3adkhbgm7wm5fenk4dbppauxhctguugj894ggm5b|20 3 2 96 dxsnrhpj2vf25mw866jncfa9qkky3h2qajaxj7hh|21 3 2 95 j9t9k3vq2sn7gqpc7fu3xhswedeu2aqyd8sp75ab|22 3 2 96 acbb5cnscuukjn3vsd2euj24xeaapt5avfp8bh68|23 3 2 103 hj3wtfr6xwgfm477gjrfj992qwdt3tndr7eypy3g|24 9 1 98 ghtfr3g4dt2e7sfpbevc4awnbjdhy7ueur9rgtnw|25 3 3 95 ea7g6baquhk95hcer7e99hwp53eef9jdswy5qv7x|26 3 3 98 cypea9jkbgxya5jcgs7pchpfg3q7vrs5cyee7th6|27 3 3 96 e76unagmge444fs7xmx6uq7qswcxubsbgfntc6e9|28 3 3 95 sq6v2vdugrmpbqxhcdn9vyq6af9wy4gfqncv989u|29 3 3 95 kqmmaxwvg2wj4snqjymctq4bg9tjgjtjfabx3u4g|30 3 3 95 6jpy2bb3rgc2uw7723u8nt59sx6w5m98adrjac5e|31 3 3 95 6y6evdtujcr9xy7aq5fxrpkpdxknv6htf3bp6wpn|32 3 3 179 8cht47qecjknrxaccfsetyhmb9bdmc58b8fa5srk|33 3 3 181 rxtcum9tq2dkx29nag3s89ms8v2nktsw6vvdc2ee|34 3 3 181 dmqn7g8u5mykmsgfehap86fjff94w3xx3me5dxcf|35 3 3 178 hfreamu6htpeusty7d8s87mphv3q5v3d9989hc55|36 3 3 174 2vgm63p7u6b343eubvmjwx6rfwxjhd772wvbbuer|37 3 3 94 dauxudkfw7d95vr5uafqsabvq6f9nb89kmr7sbyj|38 3 3 95 6yydn39puadmqe2ueks73suknrfvwvb6bnr5gfwa|39 3 3 95 x9fd5f6ka7jkb57nhst98nsfnwshykpkx9h5ktpx|40 3 3 179 d28rvd4y6drcpnndes8yeh77hxsbnjbcdre5qraw|208 7 2 16 jd3cdk86b9b7f7g7bk5nugy2rgsh7jd3dxavar7t|209 10 2 17 9u9bjqgp8ef4c4ubykbpawvp99t6dtkcfa5cachq|210 10 2 18 an5ndbfnus8naguvy4nmy7nswkjr2p84xv9uf7ka|211 10 2 17 frgu45gr2mmeycchxkx4sgh4rsqr6ppdxrmwvgtx|212 10 2 19 23ggtasqtktma59vewhy933x364kuf3htpe9xy3f|213 10 2 20 a33qd7xs9fbqkybkv6869mgmhhqsp4g98t8272vk|214 10 2 18 9u9bjqgp8ef4c4ubykbpawvp99t6dtkcfa5cachq|215 10 2 18 nr85m75t9c58kbhkm4ncdj784tgp5ydgn8tqewnn|216 10 2 19 3dgm7uaupkh6mqwkk6y32xsugmujcrppu7mhs2jr|217 10 2 17 d4p2etfvngbmm25kb3e95vgf3wkgsnkwak882wau|218 10 2 16 uuvrk92d4sxewf8xnagch6f35r6wpxtn5ym353x9|219 10 2 17 23ggtasqtktma59vewhy933x364kuf3htpe9xy3f|220 10 2 16 8665tdp9n2ntk9x8f6c2cnbs44qseegpaf9km5c3|221 10 2 16 g9nnub4tqkhbkaj9a57vvsa6ad99uqpgfwnwyuq3|222 10 2 16 g6qbdauc4v6ww52xwd36d8qfjfdy93wepk3cu687|223 10 2 18 uxt44a9uqgatkmr9y2m42qyqup27amkpvb9k8rf6|224 10 2 18 8n2gaaeupd4bkwx9qx3a5npbexs4pggwbquagn79|225 10 2 18 kubh3duamwebkk6873s7gk2dndgqubdwqutav246|226 10 2 16 xekt3e5hqf8thc2n6k2ry8bvb7x6nnhdwcf5y53m|227 10 2 18 33gp4d6djw62wqfm29g45b8jvmpdtk2uc44xwvrr|228 10 2 19 6hae3h24jv32ugq27sur5tjqd6mc8myjd5agn8c9|229 10 2 17 drp5acbehtwhw3nkr6wa99w6fwea9fw4sgnn6sgu|230 10 2 17 reuhhcgfgqqywdukg4cgd6nr2778pcua8v9bep9w|231 10 2 17 pb5f9k4nc8pq6wmcxw6xcch6yc2g7fbxaaphk9dw|232 10 2 18 jqmn2pt78rqefq5q98jrc23df2wscjuvbpw62gyf|233 10 2 16 ves49ny87nhwf3bqy6yxgxrx2bnpres5r4hu9dqh|234 10 2 18 4hfp9rur24c5r7242dtxkjys39bvbd8a8uc8xh25|235 10 2 21 6m8rhh9j7kdehn9bjh2gmd5d44gmsaqm6fv2sxu5|236 10 2 18 5kgp9hbfjd9nbc44cnxa85vbbtn74n8pbmhf6va5|237 10 2 17 dbs5s8hmwkbw4rraq3hp73xvmbtf4jknje3d2c95|238 10 2 18 ph9e45buyqa4h5n7eycv9atjfdj9sgwsadnb2649|239 10 2 17 vapvwhh5r7m54mtkew4g27a6h35ucdqjak5hh7a7|240 10 2 18 xgdbbsm9vypr3989vjapb3uwdav8yksjhern76cr|241 10 2 18 369kg9bgqrpbnssnqqqpq87rr485auup9egrwgbf|242 10 2 18 mjxqf7hcj2t6d9ywmmpgatd2bxutteckrcn5c5pe|243 10 2 17 2atcqrkvhku694ynjb27wuxw4fjkg9xma85t32h9|244 10 2 18 xbxe2gm2wv5w37gu7t7drubwtnxx39dd4m44pkr7|245 10 2 17 rd7gmvnaqfpfmdf9ftgteu4wb2sn8aaxpexkxq73|246 10 2 16 5mfgqhmtadbh5234b7ctybhhgysvtfcckmgsn9ca|247 10 2 17 m2bwvqndmusgs7he3pat2n6uqy55fs4ywbqvc7d6|248 10 2 18 xahp4ttd4vd858bdrxctxdhcx2t7h7dfr76mdy5e|249 10 2 16 2ue2q8r88rxpptd64tuew7uaukcxknbwda2ejbvp|250 10 2 18 ujg84gxs292dp2nfhkuev9u5bne9bdc2kup9b4mu|251 10 2 14 w9a8ceter5ym5xfy6pgenn6vrhex4vm7ah9vep6j|252 10 2 17 qbhbxuvpjph6q6ecepstanwv9w9n9vhrub6dpske|253 10 2 17 a5xm995nj2e64m69qx9frq3ryjj2pnu7f4myb8yc|254 10 2 17 7qnbkea5mfsfbf3wvx8uk4b6gvsrd4p9cjftf4jq|255 10 2 17 bu9qnyd5cykcgyxer49u3xhvkw5se9cgs26pghec|256 10 2 16 3kv7n3esebyadjhpjf8a3qkyjke3gm2fr593kvhs|257 10 2 19 5whbntfq65fn9gk4cbjw576kx6nbtte73jm265ct|258 10 2 17 8q4utwp6bv3fm49pyqfqq5y7s2nayqnru62fbqrp|259 10 2 18 9nqcstp3ktc4uqv4qxe5ke8qtbtqyefqk48gptjv|260 10 2 18 cc4n44r4hpkmdpg5w79jhcrwdkqn8sqxxcunhteu|261 10 2 17 n7d26tpmkr3x82pxsvscwmue7bn2gf8ma38wy9ka|262 10 2 17 xpea2vxvmv24bsbskb7rx87p2sjsr32u6783bmm3|263 10 2 16 yf64da2y9txym4af2b2r3vfdhr9b2rg5thp8rgps|264 10 2 17 wctr36ftxamdsm8pw2nsth5bcj7c4xyq7c4u7nfj|265 10 2 18 rkn5kk6fs2c9ckkh2kuu72efthtgtwe7u6rdvham|266 10 2 15 gku2pu3fqysav8ykgv832383thxhnes8s2tvfmfg|267 10 2 15 2xuyyqgregstpf6xbnhvgf9aba497khxfu63mc8u|268 10 2 18 nugpgmf2fjhg558urhsanktjqnjwber9m8cpu4s4|269 10 2 16 byyuqfhj2nmjag7nahd4xkbjqe7cnfhdtt5pdbns|270 10 2 17 wp3nyrseaxs7vmjwc2t5axqxgcp54vns5hsaevvw|271 10 2 17 mf7nr76jdt5bjahh886bea4qsntktvbq369w6fe3|272 10 2 17 vf33rh9dp8hf64ptks66kpshyajguekwwebtw5v4|273 10 2 16 e2u6j88rmpd5qjuvkg8jendqsmdn7rn9ap9rkbpe|274 10 2 17 gngy4thc6ek77uuqwpxx9x9g36vpnpj43pxcsnbt|275 10 2 16 ykey5ncf4xwqbbqvtnbrruktvtgafbfvu76xx8su|276 10 2 16 7xpkqwp2vcsvbu77xcrxutb9w6agkxe8g6dgxua4|277 10 2 19 2c95q7xry2bvn4jq7uqkku8bqpn4536btcmr6666|278 10 2 18 v47bytafjpxnuy4amw6e4mbhp8uqj4jwybcaxdub|279 10 2 18 7rk2e3a6ys28s2kc6ejtpae7xmb74rpt9fyphj9b|280 10 2 17 7a8vc3a3su65cdtqvy73cccmnpfrqwv3dv2rnk3q|281 10 2 17 pxe7hgg2qt9swtc237thbej9hx6emxw9naumjajw|282 10 2 17 wsvtsga9a428nvtwqgah7e4uyssbydmmtrakb2d8|283 10 2 17 hk2fuq3udmh9p5jtgayrxhjtu5ev45dtfk3a4drt|284 10 2 17 h8ckrdjxgnac3hudy54rtdy2298jkxrfpkrpnpyd|285 10 2 17 bnnsmrx6tgawvp4mg95gjadhavkqmhybjpq92fch|286 10 2 17 ukmdd6ukd8vu6q33ph677bw9mjkrpn7739sspfmn|287 10 2 16 qxdemprearuqyqg9wxgd8d8mfnhnthajupw9ffbf|288 10 2 17 gv5ykx34ha8uppea4bjdxywcndjb367svaxym3u6|289 10 2 17 r2qfeu2udaq9y9pnkgccq8tbtuhwc6eg5d2ucm6q|290 10 2 17 gan8qfcywd93w9nbdhk8v2as6d2647qbxbeueyf3|291 10 2 16 rkwa3n54yd47e4unq4s998t57294dtbw869w3dnu|292 10 2 18 q4jx7hdqqurju9ny96kj6twqd329bgstmx5c4t33|293 3 3 18 584te3ub8dcx9gyqyqgf25mfpbpabucs5fpkc49q|294 3 3 17 4sj25c5rxpcmd5kc9a38g5hjmxd54ebu23hbxvfw|295 3 3 17 53cqg5s8s9yrh7cq5xk9sxfkjemhpcaakxd7y3w9|296 3 3 16 y67yr4fjkfkv8352jb83g7qtbrpc49mxufk5kcru|297 3 3 17 wh4ayhhj42kd486aacpw9vrc7uq5e4cr8d4cud4k|298 3 3 17 798a4davhayew5s7h2cy3p3hwdh5u9gdedrfkxyd|299 3 3 4 tgtycy5exghgd2qknjcqam85vtbm7spxhv4nh2n3|300 3 3 19 475fvpbkbnkr6ees2xx59jbq7agv7n3wrpmkegm3|301 3 3 17 sab4v9e842ged43wq7hqeub5kmtwa3tjdtyjbrfr|302 3 3 17 j4sw36cgqbpukhpyb2geumfhfyn3nu93uucxt5nb|303 3 3 18 9hp67dwkpabraacttxuvbm2chnd3j7vy9rdj5g8y|304 3 3 15 8ag6gxtt2h932vjb5kewdkmx7skbcrprhvgdcmt6|305 3 3 18 3cvv8hst6emh5cbgb7qu63jyd72kv24ramgxah2u|306 3 3 18 y8h8aesemjhvungsfkbtggh6ehjkxctk2t9abfsy|307 3 3 18 etdmnhbdkhqu3xw6hchxyn9ugyt53p5kkbcrt6nr|308 3 3 18 66mmm9mpg4fuw48nr6hpuduh7rptbqnf8xxdn6ax|309 3 3 17 uahgfbg4vkfjcapswmu3puw6u8wve83gkdxnnte6|310 3 3 16 yy87xgf28qqwgudwgdmwq7mr4d93wrwktcfbmpr6|311 3 3 18 fbsq3fpjjktdcswf9chnhw6makmnp394yhusyga3|312 3 3 17 rt4v59ruvu7yrmkt99wdqs4avt8t9ea3sxrfca9c|313 3 3 17 9885x4s2we9hhmg73ne9aavnws626pceq9shuwnr|314 3 3 21 2j7q6dve6ntcyf2ejwqeapg4ntygpxkeem7j4qsv|315 3 3 18 bxwxpcfrymgdwd95kufsgj282bk64bdpt3ke65rw|316 3 3 17 ehuc7mjyg9xugc6w22skugw8bnmgtcahbaq7yya3|317 3 3 18 w2sx2es63fpdhywbyubmf72x5urrebwhm4n67wat|318 3 3 17 6bqyhs4uepmed7b56rpd2h9dw3g77emsrx3cvfb5|319 3 3 17 2jfk5jhrssbvnfk67ffavj4nhfy4ak6shcj8kee3|320 3 3 18 5n4aaqcex87p32gh3wf4eawyuknc9f2jr255tny9|321 10 2 16 rccwpgdtvbmkn9t47k5d2yrfhe4js3ehabn54baq|322 7 2 17 e8s54gpj8a87hsvcub2gsg6uhdyr2d7ku32bycq8|323 7 2 18 ncn3pnh6658a7dph7xwprfp5267cqgxraeq9vat6|324 7 2 17 k2qse965et7pxpyhu5rbjsd2txyfemrd7ynvt4ku|325 11 2 18 8y523ujm758rqthe6t3v4cn2wekcnkmk44qdr5pu|326 11 2 17 busy3marmtqejvj6u5b22yh82fs4a2cb5pr6uqdu|327 7 2 15 f6xtytspsyb53euq4k6vd83qvuqwvcxh5jjw932h|328 7 2 18 y82kknar4ku4auq9d6m627uxn4pcfhtmbc2u6b7x|329 7 2 15 9r43mpyre4k25fmb38xmbbra8bqt2q7tp599kcbc|330 10 3 17 72rw79hcqp2nq4kk24ynn26e7evc66gfmv34jfcx|331 10 3 16 y93gagek5q523a2x4jdcbsddaq379mbsbq3qn5w4|332 10 3 17 kvk66hcb36suwpf7s7y8nxvnmwny63ccs5yhu24s|333 7 2 15 sbapfg2yneqty42udv8m4kbh8y3kpf6qhyy86sgk|334 7 2 17 xdxtctp4yrbew54ycfgpq28kdk9xc37xtr9p6q4w|335 10 3 18 kss7wg8jxd2dan6p6e2y3vtxr3trw9q9qeuk94f6|336 7 2 16 5prmheyffntamavc5ukyjufehnbdef7p6dqhj7hq|337 10 2 17 69mj8g8eddexpu8d72ncqrj6ap2pcwepntq7n8ts|338 3 2 18 nqp7ebb9jsemgpfqhrhteguuujrf53fh4e8px5ne|339 7 2 16 br3tup294kuvbtjpaxm72d6d9e8mrg3drq5qau5j|340 7 2 18 ysd53hjq9tdp2a7k5ewqamd9qd3ga4xsjra7fsu6|341 3 2 18 3reg7ah8bn3r7n4bcwbgmw33kh7bke5wqrhmcfek|342 10 3 16 79qar72ywepckybp5yvr54xgr3hgj8k2ane2epyj|343 3 2 17 9ebw72c9gvucxca4jgfs6prwe5tfw5xg8dc2q23t|344 10 2 16 esmsupthdmrjdc6pdbbvsx5kr623g6wwu6ackg2t|345 3 2 15 mye6k4p4ekndv9pm36r3tnbsssjp8nv86f4wn3er|346 10 3 18 a7cny4xu447ytwmxt2qrkwcgtqc43urrrskxwce3|347 7 2 16 je24d64ux5uqaw8djhmyy6x6d6tjar9xw5dfedyc|348 7 2 16 7w96txsfgsdm6mds2wd8nh749cve952kr2386n5b|349 3 2 17 yb4jvsse4p48b2btjwyhy5k57qu4kkj8qkjex5gn|350 3 2 18 kpr4kcytqrx6p6kbbbqcng22epqq9g5pxdy8b2am|351 10 2 16 4s5vwx29fvq3pm29w7bas3eg66ee7q8s5ns4t2gx|352 7 2 15 sf225kv8mrsttbajrv2cfd5j2j5tuu26p8g8jr27|353 7 2 16 f5mexk24sgqaf5hw3wav3w43sn35pdbnebx69cmk|354 9 1 15 gqtsry9urmjdxx5ae9adbc88ujes7mtccd9pnrtk|355 9 1 15 4q92v6du7fkbv8sr8dnnv3ynqa6gq4ahf8vat2rc|356 9 1 17 c6byq7y48nb6v9xa79b4b5fvcp6v6afsq2by7k8b|357 9 1 19 9a6x4xutca5tcwudkufh38vp76h96c8xcsp8vcm3|358 9 1 17 5k5a4cy23p4ywhq4j7qsb4r69srtqknue2hjdsg8|359 9 1 17 sac36fyu95ahh3h5d3qe5c3q39dhwq6kakbpcu77|360 9 1 15 hnpmccga5unnmvkerkpguxyuvfjwt8338n4udwjc|361 9 1 18 t4bb6keqs7eyfj2magrkmp234my57dyygj5vmtud|362 9 1 17 f7eqvxnmd44y3kxu8dvcbmr2apf4ev6fpcy8y8cb|363 9 1 16 mv4mxu9352ts7wy2mn72nbuqp8wmyc2pdh8jf395|364 9 1 16 sqpwm8adu6aejt776fjnbt2dxrc6c49ahdp4wq29|365 3 3 16 252ugjhqu6wdhqmjck2vwq7bxu8jsg44ygk997yf|366 9 1 16 brahx96w6swc3sp2gtsaft6t65c2hmbt2xabggag|367 9 1 17 u35gvxwxajv8ehba9ugqppsyaughuybpmxmw5kh4|368 3 3 18 fttbrdyjhejwc8n2cur6rwjwjcrftwpre7x8gk6g|369 3 3 18 k6dvw5sn49gkawmuxqr6kmfegwbwt28c34bdfpmy|370 3 3 17 y9tk9cc3nx8tjfhv9q38khb2m9byukgvn85u6buq|371 9 1 19 q7jyas62s5afyyrjxeqpxvf7mm6mwbwufq7vsan4|372 9 1 18 yc8by6wb6t5k3gebx4dssrtck2t6ve9xyg8wn7gb|373 9 1 17 u5sxtwgppnn4etkx9nfpt6yj7y6snndaphseemsb|374 9 1 16 e3cp4r4b7eg9uuw84e5sdtrr5g6spqhj8rrdrgsr|375 9 1 17 b7xj5c4m93gtk8jd684dktt9925hrw43q3cn6aca|376 10 3 18 6std6wsj22ys7yrrp4v4ye5fxbvtv7835y2tkgwp|377 3 3 17 d7byn4v9r3d752a6kch55279kdse56g4nqyr755x|378 3 3 16 9us5nckqn2e7p8yf8u9eprhr32b57dhc8jpdx7s4|379 3 3 16 6d6fkkrv62ggkkjud73fxrv5kkkmqn68n9m2nmjb|380 3 3 16 mab2rk4vgfs4x7bjn7g6fkfxed4tq7hv5nnm3tv5|381 3 3 18 57f8mf2curvjy2p6bkxhj8fmg9dr2dttx6vcv262|382 3 3 19 9hruukd8fr24dtwcdgk8jt5rq5h2gwj2sm3yxrbd|383 9 1 18 y2d83ed3bpp6u2yngfcfsheuxjraskbb2vf325m9|384 3 3 16 bdxgwy32cnfm23ajegqmfug6kker8avqsr6wx2v4|385 3 3 17 cjk9nwr8jbptddyhwyq75ted34w6u7f3b5u92mfk|386 9 1 16 g8grmpc9dw7xmu4g2j2qwrkahsm2u67jgpcsp894|387 9 1 15 uxemwmfd7k26xnqak2m364twbt48dpq7ytse6xqp|388 9 1 17 h2w4evy37rpnss4g8b5bgpct9jkfepvf7563dfj9|389 9 1 16 k5wj4wfbp26uw4m6dghxs6hpfnf6kd398xyyynq3|390 9 1 16 f66uhnnx3ccs3y4abexpe6vy6ymxxptaeehvg4ae|391 9 1 16 pv67hegrbymc2fg2mb2rwtpaxvaahhf3d3dbeyfa|392 9 1 17 rb94jvvqskuvrbkcm9ss8qmr7smsx3crusttdyyd|393 9 1 18 us6ds5e33wxmqm3uhwh86t6ffefkhfk6v27enaan|394 9 1 18 k8ugr6fu6gw4dsg2mk9emwbuey6ehm9pbrcsb3nc|395 9 1 17 ufmku65b7j6xvm9gahc2sm7p4855pqvsjs8vyx5n|396 9 1 18 5s7htd2rthy5q57hap4c9bmvdtggjjrxjxa9wvvv|397 9 1 17 7cubssrmxpm6mhg8qf3cdnnf2cu4rcdhctmgskea|398 3 3 16 hcmgdbckeck6crrapgswb5enc4wc2denjadgcfvc|399 9 1 16 qpsue77sctdtmhekfq3ydchrdh3djd4g2pwq2vcm|400 9 1 16 qd2tnwc8k8yus897dg8df2dhrhxec4f45f9gcycr|401 9 1 15 ypvq4jc93r2feh76wmk4b7g6b8gpxr3h3ug6w37x|402 9 1 16 apna729mk6sb9785qe75g46ge7fx7fkts6332nxf|403 9 1 15 uu3uqdccqg5rktmeh46c4uask7g6ar6r696hcsdx|404 3 3 16 x3whwcwkgtmqndjdw5yatcs3v3x2byqxsqvkvwk3|405 9 1 16 qqpakd43x2mh49m4gu2cgm8vxx68vx2yqmyyqw9k|406 9 1 15 6vmj8dqyty63d7sgepk7ekmmsjdub9qh7ynad3bu|407 9 1 17 632uk979ed2qa7y8mkrxjpvu9prf9uwpdk7cytpx|408 3 3 18 gtek4ydv92mumumpcgky28wqufwacsrxax24tqf2|409 3 3 17 e5f4m7qmaywgwacq5p7xnctp8jujbsutvu875hk6|410 3 3 18 ft52nbg3fdb62hdj9vp8dkj88prutbcmq2a65yh5|411 3 3 16 2dgdysxa3qvfvpbm3we54kd42vc4v5kmkwr8m8j2|412 3 3 18 f9cg8dxmmfsf6rbcfm2tw6baa83s7rurjag9pktq|413 7 2 16 fgma3gn9un66qxs34fcmj6tte2bsbnb4wt94gapp|414 3 3 18 h4huyebspscfm22n9g6m6yk4ca8cqn56sraxfa9g|415 9 1 17 4kf2tbe2cth3m2uyxaq3w7mud97es38b8gtw8rx7|416 9 1 17 vrqu2rs4e5nwkm4pssmktjq5ad4k6kbm5v4wtwa9|417 3 3 17 p7anuwnybcbrvbnykvfmw7upcyr6jj2mw2ve9w6g|418 7 2 16 yjmn8th855rhbm2evaant9gqwe65aq9ym52qutjw|419 3 3 14 94dfqf2n5jgurrsr9xyhdfhnnagd4ufr9suexbrs|420 3 3 15 r9shhsauqkw85utqxf5x7wtuerkcjfpwtnfjkbtq|421 3 3 16 x5eygymyf4atndjsv36jx5e5huhqnas9ytk3etg5|422 9 1 16 6f3gqsdpppfbssbkjyrwrf2tqmw786em6sxb4fxq|423 9 1 16 vdyw547y4bvj8fqd4mtvavavcx7cfana4kujtn24|424 3 3 17 6qadct5dmvwnbxqf7y4hkr6wtdeympdnh5af8p2w|425 9 1 17 sanr75h48cdtun628uqeucew3mehxg22wecgyy5p|426 3 3 17 3pb7238g8nc466q79j3p56n7knegwqgqyjvvt6c2|427 9 1 15 v6t46hn74te8t4bru7wbtbcqm7s4kdux53evffcc|428 9 1 15 x9caqwkwxr5kw2nwvm36f8m48teea3ynvjbrrtw2|429 7 2 17 jxxhd6bchrjcv9qhdmvuyn4dsstketfweh83hwu6|430 7 2 16 e5858ag3dmp823kaunke5jy3f2n3dp3bxsm2e3jk|431 7 2 17 drmq3kqcm3xh2dtpvdsmyq7jpjb6cdxngw59knc4|432 3 3 16 bgxj6fdbyfpgm6hywgahahq8mhpj5fc28x8hb8wt|433 3 3 17 ukm9karakfbk8p4q9cfy336b6kafwjmdhyspd6g3|434 7 2 16 4es2349ctkgwa2r5d6pu4s6r6a783xyhurjfkp4j|435 9 1 15 22t6u6tyree22spfbjx26h2f5kpbefwxrup7hbt8|436 3 3 17 p7dw6tv542u8syqsbvgxp84djsf47y7assntypuu|437 10 2 16 khgjb2r3wemymcfews723ft8e3tqjawxyqxket2u|438 3 3 17 35432kdxm8xwr372fyue285dx926c7tb5t6xfas2|439 10 2 18 4pqgcs3v45a5prbqeky9r8y9cgkqxctpxb7wvhjq|440 10 2 16 ddtmbkcw3rug7xn442na248j3vam388g7dbyyv2m|441 11 2 16 xtjt4njwvfrfec92x4hx28jefmn8vremab6naf5h|442 10 2 16 hfj7ecn3uh7g9hmdxhmufdgq33newebvv52w8dqb|443 11 2 16 d94w6dtyt7beh65kwkw4hke9hxmywucunbpb49yx";
	
	/**
	 * 取得每一本漫畫的編碼
	 * @param volumn
	 * @return
	 */
	public static String getCode(String volumn) {
		String code = "";
		String[] codes = codeDb.split("\\|");
		for (int i = 0; i<codes.length; i++) {
			if (codes[i].indexOf(volumn) == 0) {
				code = codes[i];
				break;
			}
		}
		return code;
	}
	
	/**
	 * 取得該卷的最大頁數
	 * @param volumn
	 * @return
	 */
	public static int getMaxPage(String volumn) {
		String code = getCode(volumn);
		int maxPage = 0;
		try {
			maxPage = Integer.parseInt(code.split(" ")[3]);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return maxPage;
	}
	
	public static String getLink(String comicId, String volumn, String page) {
		String code = getCode(volumn);
		String num = code.split(" ")[0];
		String sid = code.split(" ")[1];
		String did = code.split(" ")[2];
		String tcode = code.split(" ")[4];
		
		String img = "";
		int p = Integer.parseInt(page);
		if (p < 10)
			img = "00" + p;
		else if (p < 100)
			img = "0" + p;
		else
			img = "" + p;
		
		int m = ((p-1)/10)%10 + ((p-1)%10)*3;
		img += "_" + tcode.substring(m, m+3);
		return "http://img"+sid+".8comic.com/"+did+"/"+comicId+"/"+num+"/"+img+".jpg";
	}
	
	/**
	 * 取得存檔圖片的名稱，規則: 漫畫名-話-編號.jpg
	 * @param i 編號
	 * @return
	 */
	public static String getFilename(int i) {
		StringBuffer fname = new StringBuffer();	// 檔案名稱名字
		if (i < 10) 
			fname.append("00" + i + ".jpg");
		else if (i < 100) 
			fname.append("0" + i + ".jpg");
		else 
			fname.append("" + i + ".jpg");
		
		return comicName+"-"+volumnNum+"-"+fname.toString();
	}
	
	/**
	 * 取得存檔路徑
	 * @param i
	 * @return
	 */
	public static String getSavedFilename(int i) {
		return SAVE_FOLDER + "/" + getFilename(i);
	}
	
	/**
	 * 寫入檔案
	 * @param cont
	 * @param i index
	 */
	public static void toFile(InputStream cont, int i) {
		try {
			BufferedImage img = ImageIO.read(cont);
			File f = new File(getSavedFilename(i));
			ImageIO.write(img, SAVE_TYPE, f);
			log.info(getFilename(i) + " done.");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 取得頁面並以InputStream型態返回
	 * @param link 頁面連結
	 * @return
	 */
	public static InputStream getContent(String link) {
		HttpGet httpget = new HttpGet(link);
		HttpResponse response = null;
		HttpEntity e = null;
		InputStream c = null;
		try {
			response = client.execute(httpget);
			e = response.getEntity();
			c = e.getContent();
		} catch (ClientProtocolException cpe) {
			cpe.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
		return c;
	}
	
	/**
	 * 取得單頁
	 * @param comicId 漫畫編號
	 * @param volumnNum 話數/卷冊
	 * @param page 頁數
	 * @return
	 */
	public static InputStream getPage(String comicId, String volumnNum, 
		String page) {
		return getContent(getLink(comicId, volumnNum, page));
	}
	
	public static InputStream getPage(String comicId, String volumnNum, 
		int page) {
		return getContent(getLink(comicId, volumnNum, String.valueOf(page)));
	}
	
	/**
	 * 取得該卷所有漫畫並寫入硬碟
	 * @param comicId
	 * @param volumnNum
	 * @return
	 */
	public static void run(String comicId, String volumnNum) {
		int maxPage = getMaxPage(volumnNum);
		for (int i = 1; i<=maxPage; i++) {
			toFile(getPage(comicId, volumnNum, i), i);
		}
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		comicName = "Kenichi";
		comicId = "3598";		// itemid
		// volumnNum = "400";		// 話
		for (int i=406;i<=443;i++) {
			volumnNum = i+"";
			run(comicId, volumnNum);
		}
	}
}
